package com.jx.flowershopmanager.home.fragment;


import android.content.Context;
import android.content.Intent;
import android.view.View;
import android.widget.TextView;

import com.jx.flowershopmanager.App;
import com.jx.flowershopmanager.R;
import com.jx.flowershopmanager.base.BaseFragment;
import com.jx.flowershopmanager.login.LoginActivity;
import com.jx.flowershopmanager.util.SPUtils;
import com.jx.flowershopmanager.widget.SubmitButton;

import java.util.Objects;

public class ProfileFragment extends BaseFragment {

    private TextView userIdText;
    private TextView userNameText;
    private SubmitButton submitButton;
    @Override
    protected int layoutId() {
        return R.layout.fragment_profile;
    }

    @Override
    protected void initView(View view) {
        userIdText = view.findViewById(R.id.userId);
        userNameText = view.findViewById(R.id.user_name);
        submitButton = view.findViewById(R.id.btn_logout_commit);
    }

    @Override
    protected void initData(Context context) {
        SPUtils spUtils = new SPUtils(requireContext(), "user");
        userIdText.setText(App.getAppUser().getId());
        userNameText.setText(App.getAppUser().getName());
        submitButton.setOnClickListener(v->{
            spUtils.remove("user");
            spUtils.remove("token");
            startActivity(new Intent(requireContext(),LoginActivity.class));
            requireActivity().finish();
        });
    }
}